import request from '@/utils/request'

/**
 * 获取文章列表信息
 * @param {*}
 * @param {*} timestamp
 * @returns
 */

export const getArticleList = (id, timestamp) => {
  return request({
    method: 'get',
    url: '/v1_1/articles', // 本地1_0  线上1_1
    params: {
      channel_id: id,
      timestamp,
      with_top: 1
    }
  })
}

/**
 * 对文章不感兴趣
 * @param {*} id
 * @returns
 */
export function dislikeArticle (id) {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}

/**
 * 举报文章
 * @param {*} articleId 文章类型
 * @param {*} type 举报类型编号
 */
export function reportArticle (id, type) {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: id,
      type
    }
  })
}

/**
 * 获取文章详情
 * @param {*} id 文章id
 * @returns
 */
export function getArticleDetaila(id) {
  return request({
    method: 'get',
    url: '/v1_0/articles/' + id
  })
}

/**
 * 取消点赞
 * @param {*} id 文章编号
 */
export const deleteLike = id => {
  return request({
    method: 'delete',
    url: '/v1_0/article/likings/' + id
  })
}

/**
 * 添加点赞
 * @param {*} id 文章编号
 */
export const addLike = id => {
  return request({
    method: 'post',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}

/**
 * 取消不喜欢
 * @param {*} id 文章编号
 */
export const deleteDisLike = id => {
  return request({
    method: 'delete',
    url: '/v1_0/article/dislikes/' + id
  })
}

/**
 * 添加不喜欢
 * @param {*} id 文章编号
 */
export const addDisLike = id => {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}
